cmake_minimum_required(VERSION 3.10)

project(deepstream_example VERSION 1.0.0)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Release)
endif()

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/output/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/output/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/output)

# set(CUDA_TOOLKIT_ROOT_DIR "/usr/local/cuda-11.4")
find_package(CUDA REQUIRED)
find_package(OpenCV REQUIRED)
find_package(PkgConfig REQUIRED)

pkg_check_modules(GST REQUIRED gstreamer-1.0)

include_directories(${CUDA_INCLUDE_DIRS})
include_directories(${GST_INCLUDE_DIRS})

set(DEEPSTREAM_DIR "/opt/nvidia/deepstream/deepstream")
set(DEEPSTREAM_INC "${DEEPSTREAM_DIR}/sources/includes")
set(DEEPSTREAM_LIB "${DEEPSTREAM_DIR}/lib")

include_directories(${DEEPSTREAM_INC})
link_directories(${DEEPSTREAM_LIB})


# set(PROJECT_SOURCE_FILES 
#         gstreamer_base.h
#         gstreamer_pipeline.h
#         gstreamer_pipeline.cpp
#         gstreamer_sourcebin.h
#         gstreamer_sourcebin.cpp
#         main.cpp)

set(PROJECT_SOURCE_FILES 
        nvds_custom_meta.cpp
        nvds_element.cpp
        nvds_pipeline_builder.cpp
        nvds_pipeline.cpp
        nvds_sourcebin.cpp
        main.cpp)

set(DEEPSTREAM_LIBS
    nvdsgst_helper
    nvds_meta
    nvdsgst_meta
    nvds_yml_parser
    nvbufsurface
    nvbufsurftransform
    nvds_batch_jpegenc
)

add_executable(${PROJECT_NAME} ${PROJECT_SOURCE_FILES})

target_link_libraries(${PROJECT_NAME} spdlog)
target_link_libraries(${PROJECT_NAME} yaml-cpp)
target_link_libraries(${PROJECT_NAME} boost_system)
target_link_libraries(${PROJECT_NAME} boost_filesystem)
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})
target_link_libraries(${PROJECT_NAME} ${CUDA_LIBRARIES})
target_link_libraries(${PROJECT_NAME} ${GST_LIBRARIES})
target_link_libraries(${PROJECT_NAME} ${DEEPSTREAM_LIBS})
